package com.livedoc.ui.application;

import org.apache.wicket.injection.Injector;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.springframework.security.core.context.SecurityContextHolder;

import com.livedoc.business.services.DocumentService;
import com.livedoc.business.services.ProjectService;
import com.livedoc.business.services.UserService;
import com.livedoc.dal.providers.RoleDataProvider;
import com.livedoc.security.SecurityUserDetails;
import com.livedoc.ui.common.components.HeaderPanel;

public class MasterPage extends WebPage {

	private static final long serialVersionUID = 8255562492976923335L;

	@SpringBean
	private UserService userService;

	@SpringBean
	private DocumentService docService;

	@SpringBean
	private RoleDataProvider roleDataProvider;

	@SpringBean
	private ProjectService projectService;

	public MasterPage() {
		super();
		Injector.get().inject(this);
	}

	@Override
	public void onInitialize() {
		super.onInitialize();
		SecurityUserDetails details = (SecurityUserDetails) SecurityContextHolder.getContext().getAuthentication()
				.getPrincipal();
		add(new HeaderPanel("header-panel", new Model<SecurityUserDetails>(details)));
	}

}
